{% extends "aside/system/base.html" %}
{% load staticfiles %}
{% block custom_tdk %}
    <title>店铺管理 - WanFeng</title>
    <meta name="description" content="店铺管理">
{% endblock %}

{% block page-title %}店铺管理{% if company %}[{{ company.NAME }} ]{% endif %}{% endblock %}

{% block app-body %}

<div class="padding">
<div class="box">

<div class="row p-a">

    <div class="col-sm-6">
        <form name="searchFrom" action="" id="searchFrom">
        <div class="input-group">

                <input type="text" class="form-control" placeholder="搜索">
                <span class="input-group-btn">
                <button class="btn white" type="button"><i class="fa fa-search"></i></button>
                </span>

            </div>
        </form>
    </div>
    <div class="col-sm-6">
        <div class="row">
            <div class="col-sm-4">
                <button class="btn btn-fw dark text-white" data-toggle="modal" data-target="#modal-addStore">添加店铺</button>
            </div>
            <div class="col-sm-8">
                <select class="custom-select" id="selectCompany">
                    <option value="0">全部公司</option>
                    {% for company in allCompany %}
                    <option value="{{ company.ID }}">{{ company.NAME }}</option>
                    {% endfor %}
                </select>
            </div>
        </div>

    </div>

</div>


<div class="table-responsive">

    <table class="table table-striped table-hover b-t">
        <thead>
        <tr>
            <th style="width:20px"><label class="ui-check m-a-0">
                <input type="checkbox" id="action-toggle">
                <i></i></label></th>
            <th>公司</th>
            <th>客户ID</th>
            <th>类型</th>
            <th>域名/IP</th>
            <th>APPSECRET</th>
            <th>REFRESHTOKEN</th>
            <th>ACCESSTOKEN</th>
            <th>REDIRECT_URL</th>
            <th>创建时间</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody id="companyListBox">
        {% for store in storeData %}
        <tr>
            <td><label class="ui-check m-a-0">
                <input type="checkbox" name="post[]" value="{{ store.ID }}">
                <i class="dark-white"></i></label></td>
            <td><a href="{% url 'system:storeList' store.COMPANY_ID%}">{{ store.NAME }}</a></td>
            <td>{{ store.CLIENT_ID }}</td>
            <td data-val="{% if store.TYPE %}{{ store.TYPE }}{% endif %}">{% ifequal store.TYPE '1' %}自营店铺{% endifequal %}{% ifequal store.TYPE '2' %}合作店铺{% endifequal %}</td>
            <td>{{ store.HOST }}{% if store.SERVICE_IP %}<br>{{ store.SERVICE_IP }}{% endif %}</td>
            <td>{{ store.APPSECRET }}</td>
            <td>{{ store.REFRESHTOKEN }}</td>
            <td>{{ store.ACCESSTOKEN }}</td>
            <td>{{ store.REDIRECT_URL }}</td>
            <td>{{ store.CREATE_DATE }}</td>

            <td class="text-right">
                <button class="btn btn-sm white editStore" data-toggle="modal" data-target="#modal-editStore" data-val="{{ store.ID }}"><i class="fa fa-edit"></i> 编辑</button>
                <button class="btn btn-sm white addUser" data-toggle="modal" data-target="#modal-addUser" data-val="{{ store.ID }}"><i class="fa fa-edit"></i> 用户授权</button>
                <button class="btn btn-sm white deleteStore" data-val="{{ store.ID }}" data-toggle="modal" data-target="#modal-deleteStore"><i class="fa fa-trash"></i> 删除</button>
            </td>
        </tr>
        {% endfor %}
        </tbody>
    </table>
</div>


<div id="modal-deleteStore" class="modal" data-backdrop="true">
    <div class="row-col h-v">
        <div class="row-cell v-m">
            <div class="modal-dialog modal-sm">
                <div class="modal-content">
                    <form role="form" action="" method="POST">
                        {% csrf_token %}
                    <input type="hidden" name="action" value="_delete"/>
                    <input type="hidden" name="deleteStoreID" id="deleteStoreID" value="0"/>
                    <div class="modal-header">
                        <h5 class="modal-title">提示</h5>
                    </div>
                    <div class="modal-body text-center p-lg">
                        <p>您确定要删除<code id="deleteStoreClientID" class=""></code>?</p>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn dark-white p-x-md" data-dismiss="modal">否</button>
                        <button type="submit" class="btn danger p-x-md" >是</button>
                    </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>

<div id="modal-editStore" class="modal black-overlay" data-backdrop="false">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title">修改店铺 <a data-dismiss="modal" class="pull-right text-muted text-lg p-a-sm m-r-sm">×</a></h5>

            </div>
            <div class="modal-body text-center p-lg m-l-1 m-r-3">
                <form role="form" action="" method="POST">
                    {% csrf_token %}
                    <input type="hidden" name="action" value="_editStore"/>
                    <input type="hidden" name="editStoreID" id="editStoreID" value="0"/>

                    <div class="form-group row">
                                    <label for="editStoreCompanyName" class="col-sm-2 form-control-label">公司名称</label>
                                    <div class="col-sm-10">
                                        <input type="text" class="form-control" id="editStoreCompanyName" name="editStoreCompanyName"  readonly>
                                    </div>
                                </div>
                    <div class="form-group row">
                                    <label for="editStoreClientID" class="col-sm-2 form-control-label">客户ID</label>
                                    <div class="col-sm-10">
                                        <input type="text" class="form-control" id="editStoreClientID" name="editStoreClientID" placeholder="CLIENT_ID">
                                    </div>
                                </div>
                    <div class="form-group row">
                        <label for="editStoreType" class="col-sm-2 form-control-label">店铺类型</label>
                        <div class="col-sm-10">
                            <select class="form-control c-select" name="editStoreType" id="editStoreType">
                                <option value="1">自营店铺</option>
                                <option value="2">合作店铺</option>
                            </select>
                        </div>
                    </div>
                    <div class="form-group row">
                                    <label for="editStoreHost" class="col-sm-2 form-control-label">主机域名</label>
                                    <div class="col-sm-10">
                                        <input type="text" class="form-control" id="editStoreHost" name="editStoreHost" placeholder="域名">
                                    </div>
                                </div>
                    <div class="form-group row">
                                    <label for="editStoreServiceIP" class="col-sm-2 form-control-label">服务器IP</label>
                                    <div class="col-sm-10">
                                        <input type="text" class="form-control" id="editStoreServiceIP" name="editStoreServiceIP" placeholder="服务器IP">
                                    </div>
                                </div>

                    <div class="form-group row">
                                    <label for="editStoreAppSecret" class="col-sm-2 form-control-label">APPSECRET</label>
                                    <div class="col-sm-10">
                                        <input type="text" class="form-control" id="editStoreAppSecret" name="editStoreAppSecret" placeholder="APPSECRET">
                                    </div>
                                </div>
                    <div class="form-group row">
                                    <label for="editStoreRedirectURL" class="col-sm-2 form-control-label">REDIRECT_URL</label>
                                    <div class="col-sm-10">
                                        <input type="text" class="form-control" id="editStoreRedirectURL" name="editStoreRedirectURL" placeholder="REDIRECT_URL">
                                    </div>
                                </div>
                    <div class="form-group row">
                                    <label for="editStoreRefreshToken" class="col-sm-2 form-control-label">REFRESHTOKEN</label>
                                    <div class="col-sm-10">
                                        <input type="text" class="form-control" id="editStoreRefreshToken" name="editStoreRefreshToken" placeholder="REFRESHTOKEN">
                                    </div>
                                </div>
                    <div class="form-group row">
                                    <label for="editStoreAccessToken" class="col-sm-2 form-control-label">ACCESSTOKEN</label>
                                    <div class="col-sm-10">
                                        <input type="text" class="form-control" id="editStoreAccessToken" name="editStoreAccessToken" placeholder="ACCESSTOKEN">
                                    </div>
                                </div>


                    <div class="form-group row m-t-md">
                        <div class="col-sm-offset-2 col-sm-12">
                            <button type="button" class="btn dark-white p-x-md" data-dismiss="modal">取消</button>
                            <button type="submit" class="btn success p-x-md" id="editBtn">提交</button>
                        </div>
                    </div>
                </form>
            </div>

        </div>
    </div>
</div>

<div id="modal-addUser" class="modal black-overlay" data-backdrop="false">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title">店铺授权 <a data-dismiss="modal" class="pull-right text-muted text-lg p-a-sm m-r-sm">×</a></h5>

            </div>
            <div class="modal-body text-center p-lg m-l-1 m-r-3">
                <form role="form" action="" method="POST" onsubmit="return checkUserForm(this);">
                    {% csrf_token %}
                    <input type="hidden" name="action" value="_addUser"/>
                    <input type="hidden" name="addUserStoreID" id="addUserStoreID" value="0"/>

                    <div class="form-group row">
                                    <label for="addUserCompanyName" class="col-sm-2 form-control-label">公司名称</label>
                                    <div class="col-sm-10">
                                        <input type="text" class="form-control" id="addUserCompanyName" name="addUserCompanyName" readonly>
                                    </div>
                                </div>
                    <div class="form-group row">
                                    <label for="addUserStoreClientID" class="col-sm-2 form-control-label">客户ID</label>
                                    <div class="col-sm-10">
                                        <input type="text" class="form-control" id="addUserStoreClientID" name="addUserStoreClientID" placeholder="CLIENT_ID" readonly>
                                    </div>
                                </div>

                    <div class="form-group row">
                        <label for="multiple" class="col-sm-2 form-control-label">选择用户</label>
                        <div class="col-sm-10" id="userSelect">
                            <select id="multiple" class="form-control select2-multiple" name="userList" multiple="multiple" data-ui-jp="select2" data-ui-options="{theme: 'bootstrap'}" style="width: 100%;">
                            <optgroup label="VIP用户">

                            </optgroup>
                        </select>
                        </div>

                    </div>

                    <div class="form-group row m-t-md">
                        <p><span>说明：</span><code>下拉选中多个，用户需为VIP组。</code></p>
                        <div class="col-sm-offset-2 col-sm-12">
                            <button type="button" class="btn dark-white p-x-md" data-dismiss="modal">取消</button>
                            <button type="submit" class="btn success p-x-md" id="editBtn">提交</button>
                        </div>
                    </div>
                </form>
            </div>

        </div>
    </div>
</div>

<div id="modal-addStore" class="modal black-overlay" data-backdrop="false">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title">添加店铺 <a data-dismiss="modal" class="pull-right text-muted text-lg p-a-sm m-r-sm">×</a></h5>

            </div>
            <div class="modal-body text-center p-lg m-l-1 m-r-3">
                <form role="form" action="{% url 'system:company' %}" method="POST" onsubmit="return checkform(this);">
                    {% csrf_token %}
                    <input type="hidden" name="action" value="_addStore"/>

                    <div class="form-group row">
                                    <label for="addStoreCompanyID" class="col-sm-2 form-control-label">公司名称</label>
                                    <div class="col-sm-10">
                                        <select class="form-control c-select" name="addStoreCompanyID" id="addStoreCompanyID">
                                            {% for company in allCompany %}
                                            <option value="{{ company.ID }}">{{ company.NAME }}</option>
                                            {% endfor %}
                                        </select>
                                    </div>
                                </div>
                    <div class="form-group row">
                                    <label for="storeClientID" class="col-sm-2 form-control-label">客户ID</label>
                                    <div class="col-sm-10">
                                        <input type="text" class="form-control" id="storeClientID" name="storeClientID" placeholder="CLIENT_ID">
                                    </div>
                                </div>
                    <div class="form-group row">
                        <label for="storeType" class="col-sm-2 form-control-label">店铺类型</label>
                        <div class="col-sm-10">
                            <select class="form-control c-select" name="storeType" id="storeType">
                                <option value="1">自营店铺</option>
                                <option value="2">合作店铺</option>
                            </select>
                        </div>
                    </div>
                    <div class="form-group row">
                                    <label for="storeHost" class="col-sm-2 form-control-label">主机域名</label>
                                    <div class="col-sm-10">
                                        <input type="text" class="form-control" id="storeHost" name="storeHost" placeholder="域名">
                                    </div>
                                </div>
                    <div class="form-group row">
                                    <label for="storeServiceIP" class="col-sm-2 form-control-label">服务器IP</label>
                                    <div class="col-sm-10">
                                        <input type="text" class="form-control" id="storeServiceIP" name="storeServiceIP" placeholder="服务器IP">
                                    </div>
                                </div>

                    <div class="form-group row">
                                    <label for="storeAppSecret" class="col-sm-2 form-control-label">APPSECRET</label>
                                    <div class="col-sm-10">
                                        <input type="text" class="form-control" id="storeAppSecret" name="storeAppSecret" placeholder="APPSECRET">
                                    </div>
                                </div>
                    <div class="form-group row">
                                    <label for="storeRedirectURL" class="col-sm-2 form-control-label">REDIRECT_URL</label>
                                    <div class="col-sm-10">
                                        <input type="text" class="form-control" id="storeRedirectURL" name="storeRedirectURL" placeholder="REDIRECT_URL">
                                    </div>
                                </div>
                    <div class="form-group row">
                                    <label for="storeRefreshToken" class="col-sm-2 form-control-label">REFRESHTOKEN</label>
                                    <div class="col-sm-10">
                                        <input type="text" class="form-control" id="storeRefreshToken" name="storeRefreshToken" placeholder="REFRESHTOKEN">
                                    </div>
                                </div>
                    <div class="form-group row">
                                    <label for="storeAccessToken" class="col-sm-2 form-control-label">ACCESSTOKEN</label>
                                    <div class="col-sm-10">
                                        <input type="text" class="form-control" id="storeAccessToken" name="storeAccessToken" placeholder="ACCESSTOKEN">
                                    </div>
                                </div>


                    <div class="form-group row m-t-md">
                        <div class="col-sm-offset-2 col-sm-12">
                            <button type="button" class="btn dark-white p-x-md" data-dismiss="modal">取消</button>
                            <button type="submit" class="btn success p-x-md" id="editBtn">提交</button>
                        </div>
                    </div>
                </form>
            </div>

        </div>
    </div>
</div>

<footer class="light lt p-a">

</footer>
</div>
</div>


{% endblock %}